<?php
class Model_Action extends Df_Model
{

    public function __construct ($id = null) {
        parent::__construct(new Model_DbTable_Action(), $id);
    }

    // $user_friends_id - array with users 
    public function getActions ($user_friends_id, $page) {
        return $this->_dbTable->fetchAll(
        $this->_dbTable->select()
            ->where('user_id IN ' . $user_friends_id)
            ->limitPage($page, 20)
            ->order('date DESC'));
    }

    /**
     * action_id: 
    	1 - change avatar
    	2 - add friend($action_help)
    	3 - add photo($action_help) to album($action_help2)
    	4 - change status
    	5 - add audio
    	6 - add video 
     */
    public function addAction ($user_id, $action_id, $action_help = null, 
    $action_help2 = null) {
        $this->_row->user_id = $user_id;
        $this->_row->action_id = $action_id;
        $this->_row->action_help = $action_help;
        $this->_row->action_help2 = $action_help2;
        $this->_row->date = date("Y:m:d H:i:s");
        
        $this->_row->save();
    }
}